package com.yc.RSS;


import lombok.Data;

import java.io.Serializable;
import java.io.StringWriter;
import java.util.Date;

/**
 * @author zwei
 * @create 2024-07-23 20:33
 */
@Data
public class CommonInformationItem implements Serializable {
    private String title;   //item的标题
    private String textDate;   //item的发布时间
    private Date date;   //转为Date类型
    private String link;    //item的链接
    private StringBuffer description; //item的描述

    private String id;  //item的id
    private String source;  //item源名称

    public void addDescription(String txt) {
        this.description.append(txt);
    }

    public CommonInformationItem() {
    }

    public CommonInformationItem(String source) {
        this.source = source;
    }

    /**
     * 生成 词条item在磁盘上的文件名
     *
     * @return source_描述的hashcode.xml
     */
    public String getFileName() {
        StringWriter writer = new StringWriter();
        writer.append(source);
        writer.append("_");
        writer.append(String.valueOf(title.hashCode()));
        writer.append(".xml");
        //writer.append(source).append("_").append(String.valueOf(Objects.hashCode(title))).append(".xml");
        return writer.toString();
    }
}
